package com.bite.maven_demo;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("/param")
public class ParamController {
    @RequestMapping("/m1/int")
    public String method1(String name) {
        return "接收到参数name："+ name;
    }
    public Object method1GetInt(int age) {
        return "接收到参数age: "+ age;
    }
    @RequestMapping("/m2")
    public Object method2(String name,String password) {
        return "接收到参数name: "+ name +",password: "+ password;
    }
    @RequestMapping("/m3")
    public Object method3(Person p){
        return p.toString();
    }
    /*@RequestMapping("/m4")
    public Object method4(@RequestParam("time") String createtime) {
        return "接收到参数createtime: "+ createtime;
    }*/
    @RequestMapping("/m4")
    public Object method4(@RequestParam(value = "time",required = false) String createtime) {
        return "接收到参数createtime: "+ createtime;
    }
    @RequestMapping("/m5")
    public String method5(String[] arrayParam) {
        return Arrays.toString(arrayParam);
    }
    @RequestMapping("/m6")
    public String method6(@RequestParam List<String> listParam) {
        return "size:"+listParam.size()+",listParam:"+listParam;
    }

}
